/* 
 * File:   main.cpp
 * Author: pigeon
 *
 * Created on November 22, 2008, 8:09 PM
 */

#include <stdlib.h>

#include "fileList.h"
#include "fileList.h"
#include "convertor.h"
#include <boost/timer.hpp>
#include "commandLineParser.h"



/*
 * 
 */
int main(int argc, char** argv)
{
    CCommandLineParser parser;    
    try
    {
        if(!parser.parseCommandLine(argc,argv))
            return 0;
      
        boost::timer timer;    
        CFileList filesList(numberOfWorkers);
        filesList.buildFilesList(parser.getInputFolder());
        filesList.createOutputFolder(parser.getOutputFolder());
        {
            CConvertor convertor;
            convertor.Start(filesList);
        }
        std::cout<<"Took "<< timer.elapsed() << " seconds to complete convertation\n";    
    }
    catch(std::runtime_error& e)
    {
        std::cerr << "Error: " << e.what() << "\n";
        parser.printHelp();
        return 1;
    }
    catch(...)
    {
        std::cerr << "Exception of unknown type!\n";
    }    
    return (EXIT_SUCCESS);
}

